﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:DateRangeSlider="clr-namespace:DeepEarth.BingMapsToolkit.Client.Controls"
    xmlns:ToolPanel="clr-namespace:DeepEarth.BingMapsToolkit.Client.Controls;assembly=DeepEarth.BingMapsToolkit.Client.Controls.ToolPanel"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:inputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/DeepEarth.BingMapsToolkit.Client.Common;component/Resources/CommonStyles.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="DateRangeSlider:DateRangeSlider">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="Background" Value="#7fffffff" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DateRangeSlider:DateRangeSlider">
                    <Border Padding="{TemplateBinding Padding}">
                        <Grid>
                            <Rectangle Height="2" Fill="Black" VerticalAlignment="Center" Margin="2.5,0,2.5,0" />
                            <Border x:Name="SelectedRangeBorder" Margin="0">
                                <Grid>
                                    <Grid.Resources>
                                        <Style x:Key="EndThumbStyle" TargetType="Thumb">
                                            <Setter Property="Background" Value="#FF1F3B53"/>
                                            <Setter Property="BorderThickness" Value="1"/>
                                            <Setter Property="IsTabStop" Value="False"/>
                                            <Setter Property="BorderBrush">
                                                <Setter.Value>
                                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                        <GradientStop Color="#FFA3AEB9" Offset="0"/>
                                                        <GradientStop Color="#FF8399A9" Offset="0.375"/>
                                                        <GradientStop Color="#FF718597" Offset="0.375"/>
                                                        <GradientStop Color="#FF617584" Offset="1"/>
                                                    </LinearGradientBrush>
                                                </Setter.Value>
                                            </Setter>
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="Thumb">
                                                        <Grid Background="Transparent">
                                                            <VisualStateManager.VisualStateGroups>
                                                                <VisualStateGroup x:Name="CommonStates">
                                                                    <VisualState x:Name="Normal"/>
                                                                    <VisualState x:Name="MouseOver">
                                                                        <Storyboard>
                                                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity">
                                                                                <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                                                            </DoubleAnimationUsingKeyFrames>
                                                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                                                <SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF"/>
                                                                            </ColorAnimationUsingKeyFrames>
                                                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
                                                                                <SplineColorKeyFrame KeyTime="0" Value="#CCFFFFFF"/>
                                                                            </ColorAnimationUsingKeyFrames>
                                                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
                                                                                <SplineColorKeyFrame KeyTime="0" Value="#7FFFFFFF"/>
                                                                            </ColorAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Pressed">
                                                                        <Storyboard>
                                                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
                                                                                <SplineColorKeyFrame KeyTime="0" Value="#FF6DBDD1"/>
                                                                            </ColorAnimationUsingKeyFrames>
                                                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity">
                                                                                <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                                                            </DoubleAnimationUsingKeyFrames>
                                                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                                                                <SplineColorKeyFrame KeyTime="0" Value="#D8FFFFFF"/>
                                                                            </ColorAnimationUsingKeyFrames>
                                                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                                                <SplineColorKeyFrame KeyTime="0" Value="#C6FFFFFF"/>
                                                                            </ColorAnimationUsingKeyFrames>
                                                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
                                                                                <SplineColorKeyFrame KeyTime="0" Value="#8CFFFFFF"/>
                                                                            </ColorAnimationUsingKeyFrames>
                                                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
                                                                                <SplineColorKeyFrame KeyTime="0" Value="#3FFFFFFF"/>
                                                                            </ColorAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Disabled">
                                                                        <Storyboard>
                                                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity">
                                                                                <SplineDoubleKeyFrame KeyTime="0" Value=".55"/>
                                                                            </DoubleAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                </VisualStateGroup>
                                                                <VisualStateGroup x:Name="FocusStates">
                                                                    <VisualState x:Name="Focused">
                                                                        <Storyboard>
                                                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
                                                                                <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                                                            </DoubleAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Unfocused"/>
                                                                </VisualStateGroup>
                                                            </VisualStateManager.VisualStateGroups>
                                                            <Border x:Name="Background" Background="White" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2" Margin="0,5">
                                                                <Grid Margin="1" Background="{TemplateBinding Background}">
                                                                    <Border x:Name="BackgroundAnimation" Opacity="0" Background="#FF448DCA"/>
                                                                    <Rectangle x:Name="BackgroundGradient">
                                                                        <Rectangle.Fill>
                                                                            <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
                                                                                <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                                                                <GradientStop Color="#F9FFFFFF" Offset="0.375"/>
                                                                                <GradientStop Color="#E5FFFFFF" Offset="0.625"/>
                                                                                <GradientStop Color="#C6FFFFFF" Offset="1"/>
                                                                            </LinearGradientBrush>
                                                                        </Rectangle.Fill>
                                                                    </Rectangle>
                                                                </Grid>
                                                            </Border>
                                                            <Rectangle x:Name="DisabledVisualElement" Fill="#FFFFFFFF" RadiusX="2" RadiusY="2" IsHitTestVisible="false" Opacity="0" Margin="0,15"/>
                                                            <Rectangle x:Name="FocusVisualElement" Stroke="#FF6DBDD1" StrokeThickness="1" RadiusX="1" RadiusY="1" Margin="1,6" IsHitTestVisible="false" Opacity="0"/>
                                                            <StackPanel HorizontalAlignment="Center" Orientation="Horizontal" Margin="0,8" MaxHeight="10">
                                                                <Rectangle Width="1" Fill="Black"/>
                                                                <Rectangle Fill="Black" Width="1" Margin="1,0,0,0"/>
                                                            </StackPanel>
                                                        </Grid>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </Grid.Resources>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>

                                    <Thumb x:Name="RangeCenterThumb"
                                       Grid.Column="1"
                                       Cursor="Hand"
                                       Margin="-5,0,-5,0"
                                       BorderBrush="{TemplateBinding BorderBrush}"
                                       BorderThickness="{TemplateBinding BorderThickness}"
                                       Background="{TemplateBinding Background}"
                                       >
                                        <Thumb.Style>
                                            <Style TargetType="Thumb">
                                                <Setter Property="Template">
                                                    <Setter.Value>
                                                        <ControlTemplate TargetType="Thumb">
                                                            <Grid Background="Transparent">
                                                                <Border BorderBrush="{TemplateBinding BorderBrush}"
                                                                BorderThickness="{TemplateBinding BorderThickness}"
                                                                Background="{TemplateBinding Background}"
                                                                CornerRadius="3"
                                                                />
                                                            </Grid>
                                                        </ControlTemplate>
                                                    </Setter.Value>
                                                </Setter>
                                            </Style>
                                        </Thumb.Style>
                                    </Thumb>

                                    <Thumb x:Name="RangeStartThumb" 
                                       Cursor="SizeWE"
                                       Width="10"
                                       Style="{StaticResource EndThumbStyle}"
                                       BorderBrush="{TemplateBinding BorderBrush}"
                                       BorderThickness="{TemplateBinding BorderThickness}"
                                       />



                                    <Thumb x:Name="RangeEndThumb"
                                       Grid.Column="2" 
                                       Cursor="SizeWE"
                                       Width="10"
                                       Style="{StaticResource EndThumbStyle}"
                                       BorderBrush="{TemplateBinding BorderBrush}"
                                       BorderThickness="{TemplateBinding BorderThickness}"
                                       />

                                </Grid>
                            </Border>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="DateRangeSlider:DateRangeDisplayPanel">
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="FontSize" Value="10"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DateRangeSlider:DateRangeDisplayPanel">
                    <ToolPanel:ToolPanel x:Name="PART_toolPanel">
                        <ToolPanel:ToolPanel.Content>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                                <TextBlock x:Name="PART_dateFromTextBlock" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}"/>
                                <TextBlock Text=" -> " Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}"/>
                                <TextBlock x:Name="PART_dateToTextBlock" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}"/>
                            </StackPanel>
                        </ToolPanel:ToolPanel.Content>
                        <ToolPanel:ToolPanel.Options>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition></ColumnDefinition>
                                    <ColumnDefinition></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition></RowDefinition>
                                    <RowDefinition></RowDefinition>
                                    <RowDefinition></RowDefinition>
                                </Grid.RowDefinitions>
                                <controls:DatePicker SelectedDateFormat="Short" x:Name="PART_dateFromSelect" SelectedDate="{Binding Path=ValueLow, Mode=TwoWay}" Grid.Column="0" Grid.Row="0" Style="{StaticResource DatePickerStyle}" />
                                <inputToolkit:TimePicker x:Name="PART_timeFromSelect" Value="{Binding Path=ValueLow, Mode=TwoWay}" Grid.Column="1" Grid.Row="0" />
                                <controls:DatePicker SelectedDateFormat="Short" x:Name="PART_dateToSelect" SelectedDate="{Binding Path=ValueHigh, Mode=TwoWay}" Grid.Column="0" Grid.Row="1" Style="{StaticResource DatePickerStyle}" />
                                <inputToolkit:TimePicker x:Name="PART_timeToSelect" Value="{Binding Path=ValueHigh, Mode=TwoWay}" Grid.Column="1" Grid.Row="1" />
                                <Button x:Name="PART_updateButton" Content="Update" Grid.Column="1" Grid.Row="2" Style="{StaticResource ButtonStyle}" />
                            </Grid>
                        </ToolPanel:ToolPanel.Options>
                    </ToolPanel:ToolPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

